package com.tianyi.wz.walkinggame.common;

import android.app.Activity;
import android.content.pm.PackageManager;

public class VersionComon {

    public static String getVersionName(Activity activity){
        if(activity==null){
            return "";
        }
        String versionName = "";
        try {
            versionName = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionName ;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionName;
    }

    public static int getVersionCode(Activity activity){
        if(activity==null){
            return 0;
        }
        int versionCode = 0;
        try {
            versionCode = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0).versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return versionCode;
    }

}
